Skip to content

[6.x] Avoid calling ->startOfDay() on date range dates#13865

Merged
jasonvarga merged 2 commits into6.xfrom
date-range-augmentation
Feb 20, 2026
Merged

[6.x] Avoid calling ->startOfDay() on date range dates#13865
jasonvarga merged 2 commits into6.xfrom
date-range-augmentation

Conversation

@duncanmcclean
Copy link
Copy Markdown
Member

This pull request avoids calling ->startOfDay() when augmenting date ranges to avoid situations where the user selects one date but it saves another, which may cause the wrong date to be displayed on the frontend.

For example: if you're in Germany and select the 2nd February, it'll save as 2026-02-01 23:00.

Related: #13839 (comment)

@ajnsn
Copy link
Copy Markdown
Contributor

ajnsn commented Feb 11, 2026

Hey @duncanmcclean — thanks for this PR. As this issue currently breaks the whole application on our end (all event date ranges are shifted by one day), we’d really appreciate it if this could be merged soon.

An alternative solution would be to set date_format: Y-m-d directly on the field, which seems causing the same issue ☺️ Do you know if this will be addressed by the augmentation change as well?

@duncanmcclean
Copy link
Copy Markdown
Member Author

duncanmcclean commented Feb 11, 2026

An alternative solution would be to set date_format: Y-m-d directly on the field, which seems causing the same issue ☺️ Do you know if this will be addressed by the augmentation change as well?

Even when this PR is merged, you shouldn't save date range dates in Y-m-d as Statamic needs the correct date & time in order to convert from your app's timezone (by default, UTC) into your browser's timezone.

@jasonvarga jasonvarga merged commit 5039ad6 into 6.x Feb 20, 2026
11 checks passed
@jasonvarga jasonvarga deleted the date-range-augmentation branch February 20, 2026 21:45
@MrMooky
Copy link
Copy Markdown

MrMooky commented Mar 2, 2026

I don't understand the "fix". When I select the date 3/21/2026, I expect it to save 3/21/2026 and not 3/20/2026. 🤔 Oddly enough, I'm not even using a range picker here but a single date select. So this PR shouldn't even have any interference with it, but it somehow does.

Screenshot 2026-03-02 at 13 35 19

@andjsch
Copy link
Copy Markdown
Contributor

andjsch commented Mar 2, 2026

@MrMooky In v6 everything is stored as a UTC timestamp. If your timezone is Europe/Berlin, you'll see the date stored as 2026-03-20 23:00. You have to make sure, that your app has set a timezone via app.timezone or statamic.system.display_timezone. Antlers will convert the dates back to the correct timezone you would expect.

@MrMooky
Copy link
Copy Markdown

MrMooky commented Mar 2, 2026

@MrMooky In v6 everything is stored as a UTC timestamp. If your timezone is Europe/Berlin, you'll see the date stored as 2026-03-20 23:00. You have to make sure, that your app has set a timezone via app.timezone or statamic.system.display_timezone. Antlers will convert the dates back to the correct timezone you would expect.

That's what I did/tried because I read that about the UTC default. The problem is, there are already lots of dates stored and when I change app.timezone from UTC to Europe/Berlin, then old dates (using 00:00) are off by a day. So in my example from before, 3/18/2026 will become 3/17/2026 in the frontend.

Simply saving the entries won't update them it seems and there are 240+ date entries in the existing system. What would the suggest fix be here?

@jasonvarga
Copy link
Copy Markdown
Member

jasonvarga commented Mar 2, 2026

If you upgraded from v5 you should not change your app.timezone.

@MrMooky
Copy link
Copy Markdown

MrMooky commented Mar 2, 2026

If you upgraded from v5 you should not change your app.timezone.

I upgraded from v5 and I haven't changed the timezone setting initially. But I noticed the issue and when changing it to Europe/Berlin it would show new dates correctly, but old dates were a day off. When using UTC it's vice-versa. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants